home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_GetCommandWidth.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  846b  |  44 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. **
  6. **  :ts=4
  7. */
  8.  
  9. #include "gtlayout_global.h"
  10.  
  11. #ifdef DO_MENUS
  12.  
  13.     /* LTP_GetCommandWidth(RootMenu *Root,ItemNode *Item):
  14.      *
  15.      *    Calculate the width of a command sequence.
  16.      */
  17.  
  18. WORD __regargs
  19. LTP_GetCommandWidth(RootMenu *Root,ItemNode *Item)
  20. {
  21.     WORD Width = 0;
  22.  
  23.         // Skip separator bars
  24.  
  25.     if(!(Item -> Flags & ITEMF_IsBar))
  26.     {
  27.             // Add in the Amiga glyph
  28.  
  29.         if(Item -> Item . Flags & COMMSEQ)
  30.             Width = TextLength(&Root -> RPort,&Item -> Item . Command,1) + 2 + Root -> AmigaWidth + 2;
  31.         else
  32.         {
  33.                 // Add in command or submenu indicator
  34.  
  35.             if(Item -> Flags & (ITEMF_Command | ITEMF_HasSub))
  36.                 Width = IntuiTextLength(((struct IntuiText *)Item -> Item . ItemFill) -> NextText) + 2;
  37.         }
  38.     }
  39.  
  40.     return(Width);
  41. }
  42.  
  43. #endif    /* DO_MENUS */
  44.